package com.fengchao.api.controller.v1;

import com.alibaba.fastjson.JSON;
import com.fengchao.api.service.SamService;
import com.fengchao.api.service.UsrService;
import com.fengchao.model.entity.comm.CustomBizException;
import com.fengchao.model.entity.comm.Message;
import com.fengchao.model.entity.comm.ResponseParameter;
import com.fengchao.util.common.CommonValidator;
import com.vdurmont.emoji.EmojiParser;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.fengchao.api.config.Constant.*;

/**
 * 艺人动态
 * Created by http://my.oschina.net/wangnian on 2016/8/11.
 */
@RestController
@RequestMapping("/v1/sam")
public class SamController {

    @Autowired
    private SamService samService;
    @Autowired
    private UsrService usrService;

    private static Logger logger = LoggerFactory.getLogger(SamController.class);

    /**
     * 获取全部艺人动态
     *
     * @return
     */
    @ApiOperation(value = "(APP/WEB)获取全部艺人动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, </br>message:获取成功, </br>data: {</br>&nbsp;&nbsp;total：1(艺人动态的总数目),</br>&nbsp;&nbsp;info:[</br>&nbsp;&nbsp;&nbsp;{</br>&nbsp;&nbsp;&nbsp;&nbsp;headIcon：http://aaa.png (艺人App头像),</br>&nbsp;&nbsp;&nbsp;&nbsp;isLike：1 (是否喜欢, 1:喜欢 0:不喜欢 ),</br>&nbsp;&nbsp;&nbsp;&nbsp;optInCount：2 (点赞的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoImage：http://aaa.png (动态分享视频的缩约图)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;nameDisplay：张靓颖 (艺人展示名称),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistId：1 (艺人ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoUrl：http://aaa.png (分享的视频链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedCount：2 (分享的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedImageUrl：http://aaa.png (分享的图片链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedUrl：http://aaa.png (分享的链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;nationality：aaa (艺人的国籍)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;isFocus：1 (是否关注, 1: 是 0: 否),</br>&nbsp;&nbsp;&nbsp;&nbsp;createTime：1472024021000 (创建时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;style：[{id: 1(风格ID),typeName:流行(风格类型名称)}] 风格类型,</br>&nbsp;&nbsp;&nbsp;&nbsp;id：1 (分享的ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedMessage：aaa (分享的消息),</br>&nbsp;&nbsp;&nbsp;&nbsp;width：200 (分享图片的宽度),</br>&nbsp;&nbsp;&nbsp;&nbsp;height：200 (分享图片的高度)</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;&nbsp;]</br>&nbsp;}</br>}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    @RequestMapping(value = "/getArtistMessageAll/{page}/{count}", method = RequestMethod.GET)
    public ResponseParameter getArtistMessageAll(@ApiParam(value = "(APP/WEB必填)类型,APP/WEB", required = true) @RequestHeader String type,
                                                 @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                                 @ApiParam(value = "(APP/WEB必填)第几页", required = true) @PathVariable("page") Integer page,
                                                 @ApiParam(value = "(APP/WEB必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取全部艺人动态=type:{},token:{}, page:{},count:{}", type, token, page, count);
        if (!CommonValidator.isStringsNotNull(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, false);
        List<Map<String, Object>> resultList = samService.findSamArtistMessageAll(userId, page, count);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultList);
        map.put("total", samService.findSamArtistMessageAllTotal());
        responseParameter.setData(map);
        logger.debug("获取全部艺人动态响应参数={}", JSON.toJSON(responseParameter));
        logger.info("获取全部艺人动态响应参数={}", responseParameter.getStatus());
        return responseParameter;
    }

    /**
     * 获取我关注的艺人动态
     *
     * @return
     */
    @ApiOperation(value = "(APP/WEB)获取我关注的艺人动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, </br>message:获取成功, </br>data: {</br>&nbsp;&nbsp;total：1(艺人动态的总数目),</br>&nbsp;&nbsp;info:[</br>&nbsp;&nbsp;&nbsp;{</br>&nbsp;&nbsp;&nbsp;&nbsp;headIcon：http://aaa.png (艺人App头像),</br>&nbsp;&nbsp;&nbsp;&nbsp;isLike：1 (是否喜欢, 1:喜欢 0:不喜欢 ),</br>&nbsp;&nbsp;&nbsp;&nbsp;optInCount：2 (点赞的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoImage：http://aaa.png (动态分享视频的缩约图)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;nameDisplay：张靓颖 (艺人展示名称),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistId：1 (艺人ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoUrl：http://aaa.png (分享的视频链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedCount：2 (分享的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedImageUrl：http://aaa.png (分享的图片链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedUrl：http://aaa.png (分享的链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;nationality：aaa (艺人的国籍)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;isFocus：1 (是否关注, 1: 是 0: 否),</br>&nbsp;&nbsp;&nbsp;&nbsp;createTime：1472024021000 (创建时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;style：[{id: 1(风格ID),typeName:流行(风格类型名称)}] 风格类型,</br>&nbsp;&nbsp;&nbsp;&nbsp;id：1 (分享的ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedMessage：aaa (分享的消息),</br>&nbsp;&nbsp;&nbsp;&nbsp;width：200 (分享图片的宽度),</br>&nbsp;&nbsp;&nbsp;&nbsp;height：200 (分享图片的高度)</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;&nbsp;]</br>&nbsp;}</br>}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    @RequestMapping(value = "/getArtistMessageByFocus/{page}/{count}", method = RequestMethod.GET)
    public ResponseParameter getArtistMessageByFocus(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                     @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                                     @ApiParam(value = "(APP/WEB必填)第几页", required = true) @PathVariable("page") Integer page,
                                                     @ApiParam(value = "(APP/WEB必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取我关注的艺人动态=type:{},token:{},page:{},count:{}", type, token, page, count);
        if (!CommonValidator.isStringsNotNull(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, false);
        List<Map<String, Object>> resultList = samService.findSamArtistMessageByArtists(userId, page, count);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultList);
        map.put("total", samService.findSamArtistMessageByArtistsTotal(userId));
        responseParameter.setData(map);
        logger.info("获取我关注的艺人动态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    /**
     * 根据id获取动态
     *
     * @return
     */
    @ApiOperation(value = "(APP/WEB)根据id获取动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, </br>message:获取成功, </br>data: {</br>&nbsp;&nbsp;info: {</br>&nbsp;&nbsp;&nbsp;headIcon：http://aaa.png (艺人App头像),</br>&nbsp;&nbsp;&nbsp;optInCount：2 (点赞的次数),</br>&nbsp;&nbsp;&nbsp;sharedVideoImage：http://aaa.png (动态分享视频的缩约图)," +
            "</br>&nbsp;&nbsp;&nbsp;nameDisplay：张靓颖 (艺人展示名称),</br>&nbsp;&nbsp;&nbsp;artistId：1 (艺人ID),</br>&nbsp;&nbsp;&nbsp;sharedVideoUrl：http://aaa.png (分享的视频链接),</br>&nbsp;&nbsp;&nbsp;sharedCount：2 (分享的次数),</br>&nbsp;&nbsp;&nbsp;sharedImageUrl：http://aaa.png (分享的图片链接),</br>&nbsp;&nbsp;&nbsp;nationality：http://aaa.png (艺人的国籍)," +
            "</br>&nbsp;&nbsp;&nbsp;createTime：1472024021000 (创建时间),</br>&nbsp;&nbsp;&nbsp;style：[{id: 1(风格ID),typeName:流行(风格类型名称)}] 风格类型,</br>&nbsp;&nbsp;&nbsp;id：1 (分享的ID),</br>&nbsp;&nbsp;&nbsp;sharedMessage：aaa (分享的消息)</br>&nbsp;&nbsp;}</br>&nbsp;}</br>}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    @RequestMapping(value = "/getArtistMessage/{messageId}", method = RequestMethod.GET)
    public ResponseParameter getArtistMessageByMessageId(@ApiParam(value = "(APP/WEB必填)消息id", required = true) @PathVariable("messageId") Integer messageId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("根据id获取动态= messageId：{}", messageId);
        if (!CommonValidator.isStringsNotNull(messageId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Map<String, Object> resultMap = samService.findSamArtistMessageById(messageId);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultMap);
        responseParameter.setData(map);
        logger.info("根据id获取动态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    /**
     * 获取某个艺人动态
     *
     * @return
     */
    @ApiOperation(value = "(APP/WEB)获取某个艺人动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, </br>message:获取成功, </br>data: {</br>&nbsp;&nbsp;total：1(艺人动态的总数目),</br>&nbsp;&nbsp;info:[</br>&nbsp;&nbsp;&nbsp;{</br>&nbsp;&nbsp;&nbsp;&nbsp;headIcon：http://aaa.png (艺人App头像),</br>&nbsp;&nbsp;&nbsp;&nbsp;isLike：1 (是否喜欢, 1:喜欢 0:不喜欢 ),</br>&nbsp;&nbsp;&nbsp;&nbsp;optInCount：2 (点赞的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoImage：http://aaa.png (动态分享视频的缩约图)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;nameDisplay：张靓颖 (艺人展示名称),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistId：1 (艺人ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoUrl：http://aaa.png (分享的视频链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedCount：2 (分享的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedImageUrl：http://aaa.png (分享的图片链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedUrl：http://aaa.png (分享的链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;nationality：aaa (艺人的国籍)," +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;isFocus：1 (是否关注, 1: 是 0: 否),</br>&nbsp;&nbsp;&nbsp;&nbsp;createTime：1472024021000 (创建时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;width：200 (分享图片的宽度),</br>&nbsp;&nbsp;&nbsp;&nbsp;style：[{id: 1(风格ID),typeName:流行(风格类型名称)}] 风格类型,</br>&nbsp;&nbsp;&nbsp;&nbsp;id：1 (分享的ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedMessage：aaa (分享的消息),</br>&nbsp;&nbsp;&nbsp;&nbsp;height：200 (分享图片的宽度)</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;&nbsp;]</br>&nbsp;}</br>}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    @RequestMapping(value = "/getArtistMessage/{artistId}/{page}/{count}", method = RequestMethod.GET)
    public ResponseParameter getArtistMessageByArtistId(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB", required = true) @RequestHeader String type,
                                                        @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                                        @ApiParam(value = "(APP/WEB必填)艺人id", required = true) @PathVariable("artistId") Integer artistId,
                                                        @ApiParam(value = "(APP/WEB必填)第几页", required = true) @PathVariable("page") Integer page,
                                                        @ApiParam(value = "(APP/WEB必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取某个艺人动态=type:{},token:{},artistId:{}, page:{},count:{}", type, token, artistId, page, count);
        if (!CommonValidator.isStringsNotNull(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, false);
        List<Map<String, Object>> resultList = samService.findSamArtistMessageByArtist(userId, artistId, page, count);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultList);
        map.put("total", samService.findSamArtistMessageByArtistTotal(artistId));
        responseParameter.setData(map);
        logger.info("获取某个艺人动态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    /**
     * 获取我的动态
     *
     * @return
     */
    @ApiOperation(value = "(WEB)获取我的动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, </br>message:获取成功, </br>data: {</br>&nbsp;&nbsp;total：1(艺人动态的总数目),</br>&nbsp;&nbsp;info:[</br>&nbsp;&nbsp;&nbsp;{</br>&nbsp;&nbsp;&nbsp;&nbsp;headIcon：http://aaa.png (艺人App头像),</br>&nbsp;&nbsp;&nbsp;&nbsp;isLike：1 (是否喜欢, 1:喜欢 0:不喜欢 ),</br>&nbsp;&nbsp;&nbsp;&nbsp;optInCount：2 (点赞的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoImage：http://aaa.png (动态分享视频的缩约图),\" +\n" +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;nameDisplay：张靓颖 (艺人展示名称),</br>&nbsp;&nbsp;&nbsp;&nbsp;artistId：1 (艺人ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedVideoUrl：http://aaa.png (分享的视频链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedCount：2 (分享的次数),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedImageUrl：http://aaa.png (分享的图片链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedUrl：http://aaa.png (分享的链接),</br>&nbsp;&nbsp;&nbsp;&nbsp;nationality：aaa (艺人的国籍),\" +\n" +
            "</br>&nbsp;&nbsp;&nbsp;&nbsp;isFocus：1 (是否关注, 1: 是 0: 否),</br>&nbsp;&nbsp;&nbsp;&nbsp;createTime：1472024021000 (创建时间),</br>&nbsp;&nbsp;&nbsp;&nbsp;width：200 (分享图片的宽度),</br>&nbsp;&nbsp;&nbsp;&nbsp;style：[{id: 1(风格ID),typeName:流行(风格类型名称)}] 风格类型,</br>&nbsp;&nbsp;&nbsp;&nbsp;id：1 (分享的ID),</br>&nbsp;&nbsp;&nbsp;&nbsp;sharedMessage：aaa (分享的消息),</br>&nbsp;&nbsp;&nbsp;&nbsp;height：200 (分享图片的宽度)</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;&nbsp;]</br>&nbsp;}</br>}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    @RequestMapping(value = "/getArtistMessage/{page}/{count}", method = RequestMethod.GET)
    public ResponseParameter getArtistMessage(@ApiParam(value = "(必填)类型, WEB", required = true) @RequestHeader String type,
                                              @ApiParam(value = "(必填)用户token", required = true) @RequestHeader(required = false) String token,
                                              @ApiParam(value = "(必填)第几页", required = true) @PathVariable("page") Integer page,
                                              @ApiParam(value = "(必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("获取我的动态= page:{},count:{}", page, count);
        if (!CommonValidator.isStringsNotNull(type)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        List<Map<String, Object>> resultList = samService.findSamArtistMessageByUserId(userId, page, count);
        Map<Object, Object> map = new HashMap<>();
        map.put("info", resultList);
        map.put("total", samService.findSamArtistMessageByUserIdTotal(userId));
        responseParameter.setData(map);
        logger.info("获取我的动态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    /**
     * 动态点赞
     *
     * @return
     */
    @ApiOperation(value = "(APP/WEB)动态点赞（必须登录）", notes = "返回参数</br>成功:</br>{status: SUCCESS, message: 添加成功}" +
            "</br>重新登录:</br>{status: RELOGIN, message: Token失效}" +
            "</br>失败:</br>{status: FAILURE, message: 参数不全}" +
            "</br>{status: FAILURE, message: 添加失败}")
    @RequestMapping(value = "/addMessageLike", method = RequestMethod.POST)
    public ResponseParameter addMessageLike(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB") @RequestHeader String type,
                                            @ApiParam(value = "(APP/WEB必填)用户token") @RequestHeader String token,
                                            @ApiParam(value = "(APP/WEB必填)动态id", required = true) @RequestParam Integer samArtistMessageId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, ADD_FAILURE);
        logger.info("动态点赞=type:{},token:{}, samArtistMessageId:{}", type, token, samArtistMessageId);
        if (!CommonValidator.isStringsNotNull(type, token, samArtistMessageId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        boolean bool = samService.addLike(samArtistMessageId, userId);
        if (bool) {
            responseParameter = new ResponseParameter(Message.SUCCESS, ADD_SUCCESS);
        }
        logger.info("动态点赞响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    /**
     * 添加动态分享+1
     *
     * @return
     */
    @ApiOperation(value = "(APP/WEB)动态分享", notes = "返回参数</br>成功:</br>{status: SUCCESS, message: 添加成功}" +
            "</br>失败:</br>{status: FAILURE, message: 参数不全}" +
            "</br>{status: FAILURE, message: 添加失败}")
    @RequestMapping(value = "/addMessageshared", method = RequestMethod.POST)
    public ResponseParameter addMessageshared(@ApiParam(value = "(APP/WEB必填)类型, APP/WEB") @RequestHeader String type,
                                              @ApiParam(value = "(APP/WEB必填)动态id", required = true) @RequestParam Integer samArtistMessageId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, ADD_FAILURE);
        logger.info("动态分享=type:{},samArtistMessageId:{}", type, samArtistMessageId);
        if (!CommonValidator.isStringsNotNull(type, samArtistMessageId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        boolean bool = samService.addshared(samArtistMessageId);
        if (bool) {
            responseParameter = new ResponseParameter(Message.SUCCESS, ADD_SUCCESS);
        }
        logger.info("动态分享响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    /**
     * 添加动态
     *
     * @return
     */
    @ApiOperation(value = "(WEB)添加动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, message:添加成功}" +
            "</br>重新登录:</br>{status:RELOGIN,message:Token失效}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}" +
            "</br>{status:FAILURE, message:添加失败}")
    @RequestMapping(value = "/addMessage", method = RequestMethod.POST)
    public ResponseParameter addMessage(@ApiParam(value = "(必填)类型, WEB", required = true) @RequestHeader String type,
                                        @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                        @ApiParam(value = "分享的图片链接") @RequestParam(required = false) String sharedImageUrl,
                                        @ApiParam(value = "分享的视频链接") @RequestParam(required = false) String sharedVoideoUrl,
                                        @ApiParam(value = "(必填)分享的内容", required = true) @RequestParam String sharedMessage) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, ADD_FAILURE);
        logger.info("添加动态=type:{},token:{}, sharedImageUrl:{},sharedVoideoUrl:{},sharedMessage:{}", type, token, sharedImageUrl, sharedVoideoUrl, sharedMessage);
        if (!CommonValidator.isStringsNotNull(type, token, sharedMessage)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        boolean bool = samService.addMessage(userId, sharedImageUrl, sharedVoideoUrl, sharedMessage);
        if (bool) {
            responseParameter = new ResponseParameter(Message.SUCCESS, ADD_SUCCESS);
        }
        logger.info("添加动态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    /**
     * 删除动态
     *
     * @return
     */
    @ApiOperation(value = "(WEB)删除动态", notes = "返回参数</br>成功:</br>{status:SUCCESS, message:删除成功}" +
            "</br>重新登录:</br>{status:RELOGIN,message:Token失效}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}" +
            "</br>{status:FAILURE, message:删除失败}")
    @RequestMapping(value = "/deleteMessage", method = RequestMethod.POST)
    public ResponseParameter deleteMessage(@ApiParam(value = "(必填)类型, WEB", required = true) @RequestHeader String type,
                                           @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                           @ApiParam(value = "(必填)动态id", required = true) @RequestParam Integer samArtistMessageId) {
        ResponseParameter responseParameter = new ResponseParameter(Message.FAILURE, DELETE_FAILURE);
        logger.info("删除动态=type:{},token:{}, samArtistMessageId:{}", type, token, samArtistMessageId);
        if (!CommonValidator.isStringsNotNull(type, token, samArtistMessageId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        boolean bool = samService.delectMessage(userId, samArtistMessageId);
        if (bool) {
            responseParameter = new ResponseParameter(Message.SUCCESS, DELETE_SUCCESS);
        }
        logger.info("删除动态响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    /**
     * 查看最新的点赞列表
     *
     * @return
     */
    @ApiOperation(value = "(WEB)查看点赞列表", notes = "返回参数</br>成功:</br>{status:SUCCESS, </br>message:获取成功, </br>data:{</br>&nbsp;&nbsp;total: 21(点赞总数目),</br>&nbsp;&nbsp;info:[</br>&nbsp;&nbsp;&nbsp;{</br>&nbsp;&nbsp;&nbsp;&nbsp;focusTime:1472623637000(点赞时间)," +
            "</br>&nbsp;&nbsp;&nbsp;text: 给您点赞(点赞内容),</br>&nbsp;&nbsp;&nbsp;userName: aaa(用户昵称), </br>&nbsp;&nbsp;&nbsp;userIcon:http://swarm-dev.b0.upaiyun.com/usr/user_icon/1472627643358.png (用户头像), </br>&nbsp;&nbsp;&nbsp;userId: 1(用户ID)</br>&nbsp;&nbsp;&nbsp;}</br>&nbsp;&nbsp;]</br>&nbsp;}</br>}" +
            "</br>重新登录:</br>{status:RELOGIN,message:Token失效}" +
            "</br>失败:</br>{status:FAILURE, message:参数不全}")
    @RequestMapping(value = "/getLikeList/{page}/{count}", method = RequestMethod.GET)
    public ResponseParameter getLikeList(@ApiParam(value = "(必填)类型, WEB", required = true) @RequestHeader String type,
                                         @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                         @ApiParam(value = "(必填)第几页", required = true) @PathVariable("page") Integer page,
                                         @ApiParam(value = "(必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("查看点赞列表=type:{},token:{}", type, token);
        if (!CommonValidator.isStringsNotNull(type, token)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, true);
        Map<Object, Object> map = samService.getLikeList(userId, page, count);
        responseParameter.setData(map);
        logger.info("查看点赞列表响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }


    /**
     * 根据动态id获取评论动态接口
     *
     * @param type
     * @param token
     * @param samArtistMessageId
     * @param page
     * @param count
     * @return
     */
    @ApiOperation(value = "(APP)根据动态id获取评论动态接口", notes = "返回参数：成功：发布评论时间(time)、图片(headIcon)、评论内容(content)、名字(name)")
    @RequestMapping(value = "/getCommentByMessageId/{samArtistMessageId}/{page}/{count}", method = RequestMethod.GET)
    public ResponseParameter getCommentByMessageId(@ApiParam(value = "(必填)类型", required = true) @RequestHeader String type,
                                                   @ApiParam(value = "用户token") @RequestHeader(required = false) String token,
                                                   @ApiParam(value = "(必填)动态id", required = true) @PathVariable Integer samArtistMessageId,
                                                   @ApiParam(value = "(必填)第几页", required = true) @PathVariable("page") Integer page,
                                                   @ApiParam(value = "(必填)显示多少行", required = true) @PathVariable("count") Integer count) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, GET_SUCCESS);
        logger.info("根据动态id获取评论动态接口请求参数=type:{},token:{}, samArtistMessageId:{}", type, token, samArtistMessageId);
        if (!CommonValidator.isStringsNotNull(type, samArtistMessageId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        //Integer userId = usrService.getUserId(type, token, false);
        responseParameter.setData(samService.getCommentByMessageId(samArtistMessageId, page, count));
        logger.info("根据动态id获取评论动态接口响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }

    /**
     * 发表评论
     *
     * @param type
     * @param token
     * @param samArtistMessageId
     * @param samArtistMessageId
     * @param commentContent
     * @return
     */
    @ApiOperation(value = "(APP)发表评论", notes = "返回参数：成功")
    @RequestMapping(value = "/addComment", method = RequestMethod.POST)
    public ResponseParameter getCommentByMessageId(@ApiParam(value = "(必填)类型", required = true) @RequestHeader String type,
                                                   @ApiParam(value = "(必填)用户token", required = true) @RequestHeader String token,
                                                   @ApiParam(value = "(必填)动态id", required = true) @RequestParam Integer samArtistMessageId,
                                                   @ApiParam(value = "(必填)评论内容", required = true) @RequestParam String commentContent) {
        ResponseParameter responseParameter = new ResponseParameter(Message.SUCCESS, ADD_SUCCESS);
        logger.info("发表评论接口请求参数=type:{},token:{}, samArtistMessageId:{}", type, token, samArtistMessageId);
        if (!CommonValidator.isStringsNotNull(type, samArtistMessageId)) {
            throw new CustomBizException(PARAMETER_IS_NOT_COMPLETE);
        }
        Integer userId = usrService.getUserId(type, token, false);
        samService.addCommentByMessageId(samArtistMessageId, userId, EmojiParser.parseToAliases(commentContent).trim());
        logger.info("发表评论接口响应参数={}", JSON.toJSON(responseParameter));
        return responseParameter;
    }
}
